package com.example.hasee.zhcd.Adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.hasee.zhcd.R;
import com.example.hasee.zhcd.Util.GlobalParameter;

import java.util.ArrayList;
import java.util.HashMap;


/**
 * Created by hasee on 2017/9/13.
 */

public class ShipArchivesAdapter extends BaseAdapter {
    private HashMap<String, String> map = (HashMap<String, String>) GlobalParameter.get("loginmap");
    private ArrayList<HashMap<String, String>> list;
    private LayoutInflater itemInflater;
    private Context context;
    private Holder holder;

    public ShipArchivesAdapter(Context context, ArrayList<HashMap<String, String>> list) {
        this.context = context;
        this.list = list;
        this.itemInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            holder = new Holder();
            convertView = itemInflater.inflate(R.layout.ship_archives_list_item, null);
            holder.fcompany = (TextView) convertView.findViewById(R.id.fcompany);
            holder.fshipname = (TextView) convertView.findViewById(R.id.fshipname);
            holder.fshiptype = (TextView) convertView.findViewById(R.id.fshiptype);
            holder.fmaxweighnum = (TextView) convertView.findViewById(R.id.fmaxweighnum);
            holder.fphonenum = (TextView) convertView.findViewById(R.id.fphonenum);
            holder.flengthnum = (TextView) convertView.findViewById(R.id.flengthnum);
            holder.fwidthnum = (TextView) convertView.findViewById(R.id.fwidthnum);
            holder.fnetweight = (TextView) convertView.findViewById(R.id.fnetweight);
            holder.fzd = (TextView) convertView.findViewById(R.id.fzd);
            holder.fcabinnumnum = (TextView) convertView.findViewById(R.id.fcabinnumnum);
            holder.fdraintimenum = (TextView) convertView.findViewById(R.id.fdraintimenum);
//            holder.fcbsbh = (TextView) convertView.findViewById(R.id.fcbsbh);
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }

        holder.fshipname.setText((String) list.get(position).get("fshipname"));
        holder.fcompany.setText((String) list.get(position).get("fcompany"));
        holder.fmaxweighnum.setText((String) list.get(position).get("fmaxweighnum"));
        holder.fphonenum.setText((String) list.get(position).get("fphonenum"));
        holder.fshiptype.setText((String) list.get(position).get("fshiptype"));
        holder.flengthnum.setText((String) list.get(position).get("flengthnum"));
        holder.fwidthnum.setText((String) list.get(position).get("fwidthnum"));
        holder.fnetweight.setText((String) list.get(position).get("fnetweight"));
        holder.fzd.setText((String) list.get(position).get("fzd"));
        holder.fcabinnumnum.setText((String) list.get(position).get("fcabinnumnum"));
        holder.fdraintimenum.setText((String) list.get(position).get("fdraintimenum"));
//        holder.fcbsbh.setText((String) list.get(position).get("fcbsbh"));

        return convertView;
    }

    class Holder {
        private TextView fcompany;
        private TextView fshipname;
        private TextView fshiptype;
        private TextView fphonenum;
        private TextView flengthnum;
        private TextView fwidthnum;
        private TextView fnetweight;
        private TextView fzd;
        private TextView fcabinnumnum;
        private TextView fdraintimenum;
//        private TextView fcbsbh;
        private TextView fmaxweighnum;
    }
}
